package com.administrator.customviewtest.ipc.aidl;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.annotation.Nullable;
import android.util.Log;

import com.administrator.customviewtest.IMyMessageAidl;

/**
 * Created by lsp on 2017/9/22 14 10
 */

public class BookManagerService extends Service {
    private Book books;
    private IBinder binder = new IMyMessageAidl.Stub() {

        @Override
        public void setName(String name) throws RemoteException {
            books.setName(name);
        }

        @Override
        public String getName() throws RemoteException {
            return books.getName();
        }

        @Override
        public Book getBook() throws RemoteException {
            return books;
        }

        @Override
        public void setBook(Book book) throws RemoteException {
            Log.e("ssss",book==null?"书是null":"notnull");
            Log.e("ssss",book.getName()+" "+book.getId());
            books = book;
        }
    };

    @Override
    public void onCreate() {
        super.onCreate();
        books = new Book();
//        book.setName("张三");
//        book.setId(222);
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return binder;
    }
}
